function t(e) {
    wx.request({
        url: o.globalData.host + "/common/v1/ads",
        method: "GET",
        data: {
            access_token: a.getToken(),
            xcx: o.globalData.proName
        },
        success: function(r) {
            if (-500 != r.data.sta) {
                if (0 == r.data.sta) {
                    e.setData({
                        contactUserInfo: '{ "nickName": "' + a.getStorage("userInfo").nickName + '", "avatarUrl": "' + a.getStorage("userInfo").avatarUrl + '" }'
                    });
                    var o = r.data.data;
                    e.setData({
                        moreCard: o
                    });
                }
            } else a.login(function() {
                t(e), e.setData({
                    hasUserInfo: !0
                });
            }, function() {
                e.setData({
                    hasUserInfo: !1
                });
            });
        }
    });
}

var e = Object.assign || function(t) {
    for (var e = 1; e < arguments.length; e++) {
        var a = arguments[e];
        for (var r in a) Object.prototype.hasOwnProperty.call(a, r) && (t[r] = a[r]);
    }
    return t;
}, a = require("../../utils/util.js"), r = require("../../tmp/tmp.js"), o = getApp();

Page({
    data: {
        moreCard: null,
        contactUserInfo: '{ "nickName": "' + a.getStorage("userInfo").nickName + '", "avatarUrl": "' + a.getStorage("userInfo").avatarUrl + '" }'
    },
    onLoad: function() {
        e = this;
        wx.getSystemInfo({
            success: function(t) {
                e.setData({
                    wxVersion: t.version
                });
                var r = t.SDKVersion;
                a.compareVersion(r, "1.5.0") > 0 && e.setData({
                    noSupportShareImg: !0
                });
            }
        });
        var e = this;
        r.wxLogin(this, function() {
            t(e);
        });
        var o = wx.getSystemInfoSync().SDKVersion;
        this.setData({
            SDKVersion: o
        });
    },
    onShow: function() {
        var e = this;
        a.checkSession(this, function() {
            t(e);
        }), this.setData({
            contactUserInfo: '{ "nickName": "' + a.getStorage("userInfo").nickName + '", "avatarUrl": "' + a.getStorage("userInfo").avatarUrl + '" }'
        });
    },
    onHide: function() {},
    toCreate: function() {
        a.buttonClicked(this);
        var t = 1;
        1 == a.getStorage("is_first_create") ? t = 0 : a.setStorage("is_first_create", 1), 
        wx.navigateTo({
            url: "/pages/create/create?tips=" + t
        });
    },
    toCreateMini: function() {
        a.buttonClicked(this);
        var t = 1;
        1 == a.getStorage("is_first_create") ? t = 0 : a.setStorage("is_first_create", 1), 
        wx.navigateTo({
            url: "/pages/create/create?tips=" + t + "&type=mini"
        });
    },
    toCreateGame: function() {
        var t = 1;
        1 == a.getStorage("is_first_create") ? t = 0 : a.setStorage("is_first_create", 1), 
        wx.navigateTo({
            url: "/pages/create/create?tips=" + t + "&type=game"
        });
    },
    onShareAppMessage: function() {
        return e({
            title: "我发现了一个特好玩儿的抽奖小助手，特邀你一起体验~"
        }, !this.data.noSupportShareImg && {
            imageUrl: "https://cdn-xcxcustom.weiyoubot.cn/20180517/0f50393d09d4f276a7fb551c12523eb6.jpeg"
        });
    },
    toRecommend: function() {
        a.buttonClicked(this), wx.navigateTo({
            url: "/pages/recommend/recommend"
        });
    },
    toDocument: function(t) {
        a.buttonClicked(this);
        var e = this.data.SDKVersion;
        a.compareVersion(e, "1.6.4") > 0 ? wx.navigateTo({
            url: "/pages/webview/webview?url=https://mp.weixin.qq.com/s/JXFboIdFffH6Rb3Y6PEHsw"
        }) : wx.navigateTo({
            url: "/pages/document/document"
        });
    },
    postFormId: function(t) {
        a.postFormId(t.detail.formId);
    },
    toMiniProgram: function(t) {
        var e = t.currentTarget.dataset.type, r = this.data.moreCard[t.currentTarget.dataset.index];
        0 == e ? wx.navigateToMiniProgram ? wx.navigateToMiniProgram({
            appId: r.appid
        }) : wx.previewImage({
            urls: [ r.qrcode ]
        }) : 1 == e && wx.getSystemInfo({
            success: function(t) {
                var e, o = t.SDKVersion;
                (o = a.getSDKVersion(o)) < 164 ? a.showModelTips("您的微信版本太低，请升级微信~") : (e = "/pages/webview/webview?url=" + r.url, 
                wx.navigateTo({
                    url: e
                }));
            }
        });
    },
    login: function(t) {
        a.login(null, null, t.detail);
    },
    toSponsor: function() {
        wx.navigateTo({
            url: "/pages/sponsor/sponsor"
        });
    }
});